package com.zhuzi.dto.weixin.text;

import cn.hutool.core.util.StrUtil;
import com.google.common.collect.Lists;
import com.zhuzi.common.utils.LocalDateTimeUtils;
import com.zhuzi.common.utils.StringUtil;
import com.zhuzi.dto.weixin.WxContent;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.collections4.CollectionUtils;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhuzi
 * 2023/7/8 22:41
 * 新增概念提醒
 */
@Data
@Accessors(chain = true)
public class NewGnStyle extends WxContent {
    private List<GnItem> itemList;


    @Override
    public String content() {
        String title = StringUtil.centerEmoji("新增概念", 20, "\uD83C\uDFA4", "\uD83D\uDCE3");
        ArrayList<String> strings = Lists.newArrayList(title);

        if (CollectionUtils.isNotEmpty(itemList)) {
            itemList.forEach(gnItem -> {
                strings.add(gnItem.format());
                strings.add(StrUtil.repeat("——", 6));
            });

        }
        strings.add("采集时间:" + LocalDateTimeUtils.formatNormal());
        return String.join(StrUtil.LF, strings);
    }


    @Data
    @Accessors(chain = true)
    public static class GnItem {
        private String stockNm;
        private String gn;
        /**
         * 新增概念时间
         */
        private String newContent;
        private LocalDateTime publishTime;

        private String his;

        public String format() {
            return StrUtil.format("[{}]:\uD83C\uDFBA \uD83D\uDE80{}\n\n{}\n新增时间:{}\n\n历史已有概念 \uD83E\uDD1F:{}", stockNm, gn, newContent, LocalDateTimeUtils.formatNormal(publishTime), his);
        }
    }
}
